#include <iostream>
#include <cstdio>
using namespace std;

template<typename T, int size>
class CircleQueue
{
public:
	CircleQueue()
	{
		head = tail = 0;
		full = false;
	}

	void Push(T e)
	{
		if (full)
		{
			return;
		}
		data[tail] = e;
		tail = (tail + 1) % size;
		if (head == tail)
		{
			full = true;
		}
	}

	void Pop()
	{
		if (Empty())
		{
			return;
		}
		head = (head + 1) % size;
		full = false;
	}

	int Size()
	{
		if (full)
		{
			return size;
		}
		else
		{
			return (tail - head + size) % size;
		}
	}

	int Cap()
	{
		return size;
	}

	bool Empty()
	{
		return Size() == 0;
	}

	void Show()
	{
		printf("size %d, head %d, tail %d\n", Size(), head, tail);
	}
private:
	T data[size];
	int head, tail;
	bool full;
};

int main()
{
	CircleQueue<int, 5> q;
	for (size_t i = 1; i <= 8; i++)
	{
		q.Push(i);
		q.Show();
	}
	printf("========================================\n");
	for (size_t i = 1; i <= 8; i++)
	{
		q.Pop();
		q.Show();
	}
	
	return 0;
}